<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <link rel="shortcut icon" href="../../src/images/bitbug_favicon.ico" type="image/x-icon">
  <meta name="keywords" content="your keywords">
  <meta name="description" content="your description">
  <meta name="author" content="author,email address">
  <meta name="robots" content="index,follow">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="renderer" content="ie-stand">
  <title>仁和区党群服务一号通暨群众意见受理中心</title>
  <link rel="stylesheet" href="../../src/js/libs/laypage/skin/laypage.css">
  <link rel="stylesheet" href="../../src/css/base.css">
  <link rel="stylesheet" href="../../src/css/common.css">
  <link rel="stylesheet" href="../../src/css/tpl.css">
  <link rel="stylesheet" href="../../src/css/consult.css">
  <script src="../../src/js/libs/es5-shim.min.js"></script>
  <script src="../../src/js/libs/es5-sham.min.js"></script>
  <script src="../../src/js/libs/json3.min.js"></script>
  <script src="../../src/js/libs/template-web.js"></script>
</head>

<body>
  <div class="page">
    <div id="header"></div>

    <div class="menu-bar">
      <div class="container">
        <span><span class="crumb-name">当前你的位置：</span>><span>
                <a class="" href="../Home">首页</a>>
                </span>
        <span>搜索</span>
        <div class="fr search_bar clearfix">
          <input class="fl search_input" placeholder="请输入关键字..." type="text" name="sreach_input" id="js_sreach_box">
          <i class="fl search_icon"></i>
        </div>
      </div>
    </div>
    <!--正文-->
    <div class="mid_container clearfix">
      <div class="left_guide">
        <h1 class="left_guide_top_size">
          搜索
        </h1>
        <div class="left_guide_decorate">
        </div>
        <div class="left_about_us">
          SREACH
        </div>
        <div id="menu_html">
          <div class="left_white_about js_menu_list active">
            <a href="javascript:;"><span class="left_cn_about_us">搜索结果</span></a>
          </div>
        </div>
      </div>
      <div class="mid_guide">
        <div class="mid_guide_content">
          <div class="content">
            <div class="opinion" id="news_html">
            </div>
          </div>
          <div id="page1" class="laypage"></div>
        </div>
      </div>
    </div>
  </div>
  <div id="footer"></div>
  <script id="news_tpl" type="text/html">
    {{each datalist val i}}
    <div class="news_item">
      <a href="Detail.html?id={{val.id}}">
        <div class="news_item_all">
          <img src="{{val.picurls[0].smallpic}}" class="news_item_img">
          <div class="news_item_passage">
            <div class="news_item_passage_title fof">{{val.title}}</div>
            <span>{{val.abstract}}</span>
            <div class="news_item_passage_time">{{val.origin}} {{val.publishtime}}</div>
          </div>
        </div>
      </a>
    </div>
    {{/each}} {{if count == 0}}
    <div class="empty_box">
      <img src="../../src/images/null_state.png" alt="">
    </div>
    {{/if}}
  </script>
  <script src="../../src/js/libs/jquery-1.8.3.js"></script>
  <script src="../../src/js/libs/laypage/laypage.js"></script>
  <script src="../../src/js/base/common.js"></script>
  <script>
    var pageindex = 0
    var params = {
      keyword: decodeURI(window.location.href.split('?')[1].split('=')[1]),
      page: 1
    }

    $('.js_sreach_btn').on('click', function () {
      params.keyword = $('input[name="sreach_input"]').val()
      getNews(params, params.page)
    })

    $('#js_sreach_box').on('keyup', function (e) {
      if (e.keyCode == 13) {
        params.keyword = $('input[name="sreach_input"]').val()
        getNews(params, params.page)
      }
    })

    getNews(params, params.page)

    function getNews(params, page) {
      $.ajax({
        url: "http://221.10.2.222:5680/api/ow/News/ListAll",
        type: "GET",
        dataType: "json",
        data: {
          page: params.page,
          keyword: params.keyword
        },
        success: function (res) {
          console.log(res)
          var html = template('news_tpl', res);
          document.getElementById('news_html').innerHTML = html;
          laypage({
            cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
            pages: Math.ceil(res.count / 5), //通过后台拿到的总页数
            curr: page || 1, //当前页
            first: false,
            last: false,
            prev: '<',
            next: '>',
            jump: function (obj, first) {
              window.scrollTo(0, 300)
              if (!first) {
                getNews(params, obj.curr);
              }
            }
          });
        },
        error: function (e) {
          console.log(JSON.stringify(e))
        }
      })
    }
  </script>
</body>

</html>